VERSION 1.0 CLASS
BEGIN
  MultiUse = -1  'True
  Persistable = 0  'NotPersistable
  DataBindingBehavior = 0  'vbNone
  DataSourceBehavior  = 0  'vbNone
  MTSTransactionMode  = 0  'NotAnMTSObject
END
Attribute VB_Name = "TestHiResTimer"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = True
Attribute VB_PredeclaredId = False
Attribute VB_Exposed = True
Option Explicit

Private mTimer As HiResTimer

Public Sub testValidity()
givenHiResTimer
thenTimerIsValid
End Sub
Public Sub testElapsedTime()
givenHiResTimer
whenStartedThenStopped
thenElapsedTimeGT0
End Sub
Public Sub testElapsedTimeOverhead()
givenHiResTimer
whenStartedThenStopped
thenElapsedTimeLTOverhead
End Sub
Public Sub testElapsedTimeWithoutStarting()
givenHiResTimer
thenElapsedTimeIs0
End Sub


Private Sub givenHiResTimer()
Set mTimer = New HiResTimer
End Sub
Private Sub whenStartedThenStopped()
mTimer.Start
mTimer.Halt
End Sub
Private Sub thenTimerIsValid()
assert.isTrue mTimer.Valid, "Timer should be valid"
End Sub
Private Sub thenElapsedTimeGT0()
assert.isTrue mTimer.Elapsed > 0, "Timer should have run"
End Sub
Private Sub thenElapsedTimeLTOverhead()
'Overhead measured at just less than 700nS, ie less than 1uS
assert.isTrue mTimer.Elapsed < 0.000001, "Timer has an overhead"
End Sub
Private Sub thenElapsedTimeIs0()
assert.equals mTimer.Elapsed, 0, "Timer never ran"
End Sub


Public Function NumOfAsserts() As Long
NumOfAsserts = 4
End Function

